<?php
session_start();
require("../../adodb/adodb.inc.php");
require("../../Connections/forms2.php");
require_once("../../makesql.php");
//require_once("../../searchcore.php");
//require_once("../../getmyvalue.php");
require_once("../../procfunc.php");
require_once("../../firmaorigen.php");

$SQL="SELECT * FROM preguntas WHERE idpreg=$idpreg";
$preg=$forms2->Execute($SQL) or DIE ("Error en la consulta");
$idform=$preg->Fields('param1');
$origidform=$idform;
$tipo=$idform[0];
$idform=substr($idform,1);
	if ($tipo=="V"){
	$param="idvista=$idform&idap=$idap";
	} else {
	$param="idform=$idform&idap=$idap";
	}
//$forms2->debug=true;
ob_start();
if($paste<>''){
addsel($id);
?>
<?php }?>
<style>
.inbox {
    font-family: Verdana, Arial, Helvetica, sans-serif;
	text-align: center;
	border-top: 1px solid #999999;
	border-right: 1px solid #999999;
	border-bottom: 1px solid #999999;
	border-left: 1px solid #999999;
	font-size: 11px;
}
</style>
<table cellspacing="0" cellpadding="4">
  <tr>
    <td><div class='msgBox'>
      <form action="" method="get">
        <table width="100%" border="0" cellpadding="0" cellspacing="2" class="pregunta">
          <tr>
            <td colspan="3" nowrap class="smalltext">Buscar antes de cargar nueva</td>
            <td width="4%" rowspan="3" class="smalltext"><p>&nbsp;</p></td>
          </tr>
          <tr>
            <td width="9%" valign="middle" nowrap class="smalltext">D.N.I:</td>
            <td width="22%" valign="middle" nowrap><input type="text" name="dni" id="dni" value="<?=$dni;?>" maxlength="10" size="10" class="inbox"></td>
            <td width="65%" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td class="smalltext" nowrap>            </td>
            <td><span class="smalltext">
              <input type="submit" name="Submit" value="Buscar" class="inbox" />
              <input type="hidden" name="idpreg" value="<?=$idpreg;?>" />
              <input type="hidden" name="nombrecontrol" value="<?=$nombrecontrol;?>" />
              <?=$mydir;?>
              <input type="hidden" name="idap" value="<?=$idap;?>"/>
            </span></td>
            <td>&nbsp;</td>
          </tr>
        </table>
        </form>
      <?php

if ($dni<>"") {

//$forms2->debug=true;
$SQL="SELECT * FROM td_personas INNER JOIN idsent ON td_personas.id=idsent.id WHERE idpreg=1795 AND valor LIKE '%$dni%' AND idsent.estado IN ('activa','validar')";
$res=$forms2->Execute($SQL) or DIE ("Error en la consulta");
if($res->RecordCount()){
?>
      <table border="0" cellspacing="2" cellpadding="2">
        <tr bgcolor="#FFFFFF" class="seccioncolor">
          <td class="smalltext">&nbsp;</td>
          <td class="smalltext">NroDoc</td>
          <td class="smalltext">Nombre</td>
          <td class="smalltext">Apellido</td>
          <td class="smalltext">Provincia</td>
          <td class="smalltext">Partido</td>
          <td class="smalltext">Localidad</td>
          <td class="smalltext">Domicilio</td>
          <td class="smalltext">E-mail</td>
          <td class="smalltext">Origen</td>
        </tr>
        <?php
  while (!$res->EOF){
  $id=$res->Fields("id");
  if($preg->Fields('param2')){
  //----hay que chequear la vista
  $link="$basedir/RenderEdit/editnew.php?$param&child=$idpreg&childcont=$nombrecontrol&nonav=true&id=$id";
  } else {
  //----se puede agregar directamente
  $link="javascript:window.parent.tb_remove();window.parent.addsel('$id','$idpreg','".$preg->Fields('nombrecontrol')."');";
  }
  ?>
 
        <tr bgcolor="#FFFFFF">
          <td class="smalltext" align="center"><a href="<?=$link;?>" title="Cargar/agregar"> <strong><img src="../../ImagenCustom/add.gif" alt="agregar" width="16" height="16" border="0" align="absmiddle" />&nbsp;Agregar</strong></a></td>
          <td class="smalltext"><?=getvalor(1795)?></td>
          <td class="smalltext"><?=getvalor(1783)?></td>
          <td class="smalltext" align="center"><?=getvalor(1784)?></td>
          <td class="smalltext"><?=@array_shift(getvalor(1788));
		  ?></td>
          <td class="smalltext"><?=@array_shift(getvalor(1788));
		  ?></td>
          <td class="smalltext"><?=@array_shift(getvalor(1789));?></td>
          <td class="smalltext"><?=getvalor(1787);?></td>
          <td class="smalltext"><?=getvalor(1786);?></td>
          <td class="smalltext"><?=getvalor(1796);?></td>
        </tr>
        <?php
  $res->Movenext();
  }?>
      </table>
  <?php } else {

$link="$basedir/RenderEdit/editnew.php?$param&child=$idpreg&childcont=$nombrecontrol&nonav=true&id=$id";
  ?>
No se han encontrado resultados, puede incorporar la Persona en el Registro haciendo click  <a href="<?=$link;?>"><b> >>AQUI<< </b></a>para cargarla ahora.
<script language="javascript">
enabled=window.parent.document.getElementById('enabled_<?=$idpreg;?>');
disabled=window.parent.document.getElementById('disabled_<?=$idpreg;?>');
disabled.style.visibility='hidden';
disabled.style.width='0px';
disabled.style.position='absolute';
enabled.style.visibility='visible';;
</script>
      <br>
</p>
      <p>o click <a href="javascript:window.parent.tb_remove();"><strong>&gt;&gt;AQUI&lt;&lt; </strong></a>para cerrar.
      <?php }
}?>
    </div></td>
  </tr>
</table>
<?php
$out = ob_get_contents();
ob_end_clean();
echo utf8_encode($out);
?>